<?php
class SessionHandle {
	
	private $lifeTime;
	private $sessionPath;
	private $sessionId;
	
	public function SessionHandle() {
		$this->lifeTime    = $GLOBALS['_FENGTOPsso']['config']['sessiontime'];
		$this->sessionPath = $GLOBALS['_FENGTOPsso']['config']['sessionpath'];
		session_save_path($this->sessionPath);
		session_set_cookie_params($this->lifeTime); 
	}
	public function setSessionId() {
		session_start(); 
		$this->sessionId = session_id();
		$this->setCookieSessId();
		$this->changePage();
	}
	
	public function getSessionId() {
		; 
	}
	
	public function clientSession(){
		$this->getCookieSessId();
		session_id($this->sessionId);
		session_start();
		$this->changePage();
	}
	
	private function changePage() {
		@$_SESSION['UserTrack'][4] = $_SESSION['UserTrack'][3];
		@$_SESSION['UserTrack'][3] = $_SESSION['UserTrack'][2];
		@$_SESSION['UserTrack'][2] = $_SESSION['UserTrack'][1];
		@$_SESSION['UserTrack'][1] = $_SESSION['UserTrack'][0];
		$_SESSION['UserTrack'][0] = $_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]."?".$_SERVER["QUERY_STRING"];
	}
	
	private function setCookieSessId() {
		$_COOKIE['PHPSESSID'] = $this->sessionId;
		$GLOBALS['PHPSESSID'] = $this->sessionId;
	}
	
	private function getCookieSessId() {
		//$this->sessionId = $GLOBALS['PHPSESSID'];
		$selectSessId = "select `sessId` 
		                   from `onlineuser`
		                  where ticket = '".substr($_GET['ticket'], 0, -32)."'";
		
		$result = $GLOBALS['FENGTOPssoDB']->GetOne($selectSessId);
		$this->sessionId = $result['sessId'];
	}
}

?>